package org.br.erp.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.br.erp.base.Constant.SnState;
import org.br.erp.base.entity.Scmsn;
import org.br.erp.base.mapper.ScmsnMapper;
import org.br.erp.base.service.IScmsnService;
import org.br.erp.base.utils.ERPUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;
import java.util.Map;

/**
 * @Description: 单件档案
 * @Author: jeecg-boot
 * @Date:   2022-09-07
 * @Version: V1.0
 */
@Service
public class ScmsnServiceImpl extends ServiceImpl<ScmsnMapper, Scmsn> implements IScmsnService {

    @Autowired
        ScmsnMapper scmsnMapper;
    /**
     * 获取在库的序列号信息
     * @param queryMap
     * @return
     */
    @Override
    public List<Scmsn> getSnList(Map queryMap) {
        QueryWrapper<Scmsn> queryWrapper=new QueryWrapper<>();
        if(ERPUtils.ifHtppReqParamContainKey(queryMap,"companyid")){
            queryWrapper.eq("companyid",ERPUtils.getHttpReqParam(queryMap,"companyid"));
        }
        if(ERPUtils.ifHtppReqParamContainKey(queryMap,"materialid")){
            queryWrapper.eq("materialid",ERPUtils.getHttpReqParam(queryMap,"materialid"));
        }
        if(ERPUtils.ifHtppReqParamContainKey(queryMap,"warehouseid")){
            queryWrapper.eq("warehouseid",ERPUtils.getHttpReqParam(queryMap,"warehouseid"));
        }
        if(ERPUtils.ifHtppReqParamContainKey(queryMap,"sncode")){
            queryWrapper.eq("sncode",ERPUtils.getHttpReqParam(queryMap,"sncode"));
        }

        queryWrapper.eq("snstate", SnState.InStock);

        List<Scmsn> scmsnList = scmsnMapper.selectList(queryWrapper);
        return  scmsnList;
    }
}
